#include<bits/stdc++.h>
using namespace std;
int tt,n,m,l,v,d[200010],vi[200010],a[200010],t[200010],p[200010];
double f[5][200010];
int main(){
freopen("detect.in","r",stdin);
freopen("detect.in","w",stdout);
cin>>tt;
for(int b=1;b<=tt;b++){
    memset(t,0,sizeof(t));
    cin>>n>>m>>l>>v;
    for(int i=1;i<=n;i++){
        cin>>d[i]>>vi[i]>>a[i];
        d[i]=l-d[i];
        if(vi[i]>v&&a[i]>=0){
            f[1][i]=l-d[i];
            f[2][i]=l;
            continue;
        }
        if(vi[i]<=v&&a[i]<=0){
            continue;
        }
        if(vi[i]>v&&a[i]<0){
            f[1][i]=l-d[i];
            f[2][i]=f[1][i]+((vi[i]*vi[i]-v*v)/a[i]/2.0*(-1));
            continue;
        }
        d[i]-=(v*v-vi[i]*vi[i])/a[i]/2.0;
        vi[i]=v;
        f[1][i]=l-d[i];
        f[2][i]=l;
    }
    for(int i=1;i<=m;i++){
        cin>>p[i];
        for(int j=1;j<=n;j++){
            if(f[1][j]<=p[i]&&f[2][j]>=p[i]){
                t[j]=1;
            }
        }
    }
    int cnt=0;
    for(int i=1;i<=n;i++){
       if(t[i]==1)cnt++;
    }
    cout<<cnt<<" ";
    if(m==0){
        cout<<"0";
        return 0;    }
    int q[200010][3];
    for(int i=1;i<=n;i++){
            if(f[1][i]==0&&f[2][i]==0){
                continue;
            }
        int e=1;
        for(int j=1;j<=m;j++){
            if(f[1][i]<=p[j]&&f[2][i]>=p[j]){
                if(e==1)q[i][e]=j;
                e=j;
            }
        }
        q[i][2]=e;
    }
    for(int L=1;L<n;L++){
    if(q[L][1]!=0&&q[L][2]!=0){
        for(int R=L+1;R<=n;R++){
        if(q[L][1]!=0&&q[L][2]!=0&&q[R][1]!=0&&q[R][2]!=0){
            if(max(q[L][1],q[R][1])>min(q[L][2],q[R][2]))continue;
            q[L][1]=max(q[L][1],q[R][1]);
            q[L][2]=min(q[L][2],q[R][2]);
            q[R][2]=0;
            q[R][1]=0;

        }
        }

    }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(q[i][1]!=0&&q[i][2]!=0)
            ans++;
    }
    cout<<m-ans;
}
return 0;
}
